/**
 * Created by LangK on 2016/12/20.
 */
import Vue from 'vue'

const beginLoading = commit => {
  console.log(commit+" start")
  return Date.now()
}


const stopLoading = commit => {
  console.log(commit+" stop")
  return Date.now()
}


export default {
  login({commit},postdata){
    beginLoading('login');
    return Vue.http.post('/admin/system/user/V0_0_1/login',postdata).then(response => {
      stopLoading('login')
      console.log(response)
      if (response.status === 200) {
        commit('SET_USERINFO',response.body.data);
        return Promise.resolve(response.body)
      } else {
        return Promise.reject(response.data.message)
      }
    })
  }
}
